﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System;
using VCDIFF.Tools;

namespace VCDIFF.Tests
{
    
    
    /// <summary>
    ///This is a test class for SFIOIntegerTest and is intended
    ///to contain all SFIOIntegerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SFIOIntegerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Size
        ///</summary>
        [TestMethod()]
        public void GetSFIOIntegerSizeTest()
        {
            byte[] data = new byte[5] { 0x80, 0x80, 0x80, 0x80, 0x69 };
            ulong expected = 4;
            ulong actual;
            actual = SFIOInteger.Size(data);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Size
        ///</summary>
        [TestMethod()]
        public void GetSFIOIntegerSizeTest1()
        {
            byte[] data = new byte[4] { 0x7F, 0x7F, 0x80, 0x01 };
            ulong expected = 0;
            ulong actual;
            actual = SFIOInteger.Size(data);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Encode
        ///</summary>
        [TestMethod()]
        public void EncodeTest()
        {
            UInt64 value = 1000000000;
            byte[] expected = new byte[5] { 0x83, 0xDC, 0xEB, 0x94, 0x00 };
            byte[] actual = SFIOInteger.Encode(value);

            bool same = true;

            if (expected.Length != actual.Length)
                same = false;
            else
                for (int i = 0; i < expected.Length; i++)
                    if (expected[i] != actual[i])
                        same = false;

            Assert.AreEqual(true, same);
        }

        /// <summary>
        ///A test for Decode
        ///</summary>
        [TestMethod()]
        public void DecodeTest1()
        {
            BinaryReader reader = null; // TODO: Initialize to an appropriate value
            ulong expected = 0; // TODO: Initialize to an appropriate value
            ulong actual;
            //actual = SFIOInteger.Decode(reader);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for Decode
        ///</summary>
        [TestMethod()]
        public void DecodeTest()
        {
            byte[] data = new byte[4] { 0xBA, 0xEF, 0x9A, 0x15 };
            ulong expected = 123456789;
            ulong actual;
            actual = SFIOInteger.Decode(data);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for SFIOInteger Constructor
        ///</summary>
        [TestMethod()]
        public void SFIOIntegerConstructorTest()
        {
            SFIOInteger target = new SFIOInteger();
        }
    }
}
